import 'package:flutter_common_fragement/generated/json/base/json_convert_content.dart';
import 'package:flutter_common_fragement/pages/root/model/missions_entity.dart';

MissionsEntity $MissionsEntityFromJson(Map<String, dynamic> json) {
  final MissionsEntity missionsEntity = MissionsEntity();
  final List<MissionsList>? list = (json['list'] as List<dynamic>?)
      ?.map((e) => jsonConvert.convert<MissionsList>(e) as MissionsList)
      .toList();
  if (list != null) {
    missionsEntity.list = list;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    missionsEntity.total = total;
  }
  return missionsEntity;
}

Map<String, dynamic> $MissionsEntityToJson(MissionsEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['list'] = entity.list?.map((v) => v.toJson()).toList();
  data['total'] = entity.total;
  return data;
}

extension MissionsEntityExtension on MissionsEntity {
  MissionsEntity copyWith({
    List<MissionsList>? list,
    int? total,
  }) {
    return MissionsEntity()
      ..list = list ?? this.list
      ..total = total ?? this.total;
  }
}

MissionsList $MissionsListFromJson(Map<String, dynamic> json) {
  final MissionsList missionsList = MissionsList();
  final String? companyName = jsonConvert.convert<String>(json['companyName']);
  if (companyName != null) {
    missionsList.companyName = companyName;
  }
  final String? companyAvatar =
      jsonConvert.convert<String>(json['companyAvatar']);
  if (companyAvatar != null) {
    missionsList.companyAvatar = companyAvatar;
  }
  final int? missionId = jsonConvert.convert<int>(json['missionId']);
  if (missionId != null) {
    missionsList.missionId = missionId;
  }
  final String? missionName = jsonConvert.convert<String>(json['missionName']);
  if (missionName != null) {
    missionsList.missionName = missionName;
  }
  final String? provinceCode =
      jsonConvert.convert<String>(json['provinceCode']);
  if (provinceCode != null) {
    missionsList.provinceCode = provinceCode;
  }
  final String? provinceName =
      jsonConvert.convert<String>(json['provinceName']);
  if (provinceName != null) {
    missionsList.provinceName = provinceName;
  }
  final String? cityCode = jsonConvert.convert<String>(json['cityCode']);
  if (cityCode != null) {
    missionsList.cityCode = cityCode;
  }
  final String? cityName = jsonConvert.convert<String>(json['cityName']);
  if (cityName != null) {
    missionsList.cityName = cityName;
  }
  final String? areaCode = jsonConvert.convert<String>(json['areaCode']);
  if (areaCode != null) {
    missionsList.areaCode = areaCode;
  }
  final String? areaName = jsonConvert.convert<String>(json['areaName']);
  if (areaName != null) {
    missionsList.areaName = areaName;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    missionsList.address = address;
  }
  final int? startTime = jsonConvert.convert<int>(json['startTime']);
  if (startTime != null) {
    missionsList.startTime = startTime;
  }
  final int? endTime = jsonConvert.convert<int>(json['endTime']);
  if (endTime != null) {
    missionsList.endTime = endTime;
  }
  final String? missionDescription =
      jsonConvert.convert<String>(json['missionDescription']);
  if (missionDescription != null) {
    missionsList.missionDescription = missionDescription;
  }
  final double? missionMoney =
      jsonConvert.convert<double>(json['missionMoney']);
  if (missionMoney != null) {
    missionsList.missionMoney = missionMoney;
  }
  final String? missionTimeType =
      jsonConvert.convert<String>(json['missionTimeType']);
  if (missionTimeType != null) {
    missionsList.missionTimeType = missionTimeType;
  }
  final String? missionUnit = jsonConvert.convert<String>(json['missionUnit']);
  if (missionUnit != null) {
    missionsList.missionUnit = missionUnit;
  }
  final String? isDiscussPersonally =
      jsonConvert.convert<String>(json['isDiscussPersonally']);
  if (isDiscussPersonally != null) {
    missionsList.isDiscussPersonally = isDiscussPersonally;
  }
  return missionsList;
}

Map<String, dynamic> $MissionsListToJson(MissionsList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['companyName'] = entity.companyName;
  data['companyAvatar'] = entity.companyAvatar;
  data['missionId'] = entity.missionId;
  data['missionName'] = entity.missionName;
  data['provinceCode'] = entity.provinceCode;
  data['provinceName'] = entity.provinceName;
  data['cityCode'] = entity.cityCode;
  data['cityName'] = entity.cityName;
  data['areaCode'] = entity.areaCode;
  data['areaName'] = entity.areaName;
  data['address'] = entity.address;
  data['startTime'] = entity.startTime;
  data['endTime'] = entity.endTime;
  data['missionDescription'] = entity.missionDescription;
  data['missionMoney'] = entity.missionMoney;
  data['missionTimeType'] = entity.missionTimeType;
  data['missionUnit'] = entity.missionUnit;
  data['isDiscussPersonally'] = entity.isDiscussPersonally;
  return data;
}

extension MissionsListExtension on MissionsList {
  MissionsList copyWith({
    String? companyName,
    String? companyAvatar,
    int? missionId,
    String? missionName,
    String? provinceCode,
    String? provinceName,
    String? cityCode,
    String? cityName,
    String? areaCode,
    String? areaName,
    String? address,
    int? startTime,
    int? endTime,
    String? missionDescription,
    double? missionMoney,
    String? missionTimeType,
    String? missionUnit,
    String? isDiscussPersonally,
  }) {
    return MissionsList()
      ..companyName = companyName ?? this.companyName
      ..companyAvatar = companyAvatar ?? this.companyAvatar
      ..missionId = missionId ?? this.missionId
      ..missionName = missionName ?? this.missionName
      ..provinceCode = provinceCode ?? this.provinceCode
      ..provinceName = provinceName ?? this.provinceName
      ..cityCode = cityCode ?? this.cityCode
      ..cityName = cityName ?? this.cityName
      ..areaCode = areaCode ?? this.areaCode
      ..areaName = areaName ?? this.areaName
      ..address = address ?? this.address
      ..startTime = startTime ?? this.startTime
      ..endTime = endTime ?? this.endTime
      ..missionDescription = missionDescription ?? this.missionDescription
      ..missionMoney = missionMoney ?? this.missionMoney
      ..missionTimeType = missionTimeType ?? this.missionTimeType
      ..missionUnit = missionUnit ?? this.missionUnit
      ..isDiscussPersonally = isDiscussPersonally ?? this.isDiscussPersonally;
  }
}
